<template>
  <div class="monitor-box">
    <CardBox title="趋势"> </CardBox>
    <div class="content-container">
      <div class="statistics-chart" ref="speciesChart"></div>
    </div>
  </div>
</template>
<script>
import CardBox from "@/components/Global/CardBox.vue";
import {EventBus} from "../../utils/event-bus";
import * as echarts from "echarts";
import ecStat from 'echarts-stat';
export default {
  name: "Introduce",
  components: {
    CardBox,
  },
  data() {
    return {
      introduce:'',
    };
  },
  created() {
    EventBus.$on('set-multi-introduce', (message) => {
      this.introduce=message;
    });
  },
  mounted() {
    this.initChart()
  },
  methods: {
    initChart() {
      const chartDom = this.$refs.speciesChart
      if (!chartDom) return

      const chart = echarts.init(chartDom,'dark');
      echarts.registerTransform(ecStat.transform.regression);
      const data=[[365,1.54],[308,0.93],[316,1.33],[206,1.43],[284,1.34],[306,1.33]];
      const option = {
        dataset: [
          {
            source: data
          },
          {
            transform: {
              type: 'ecStat:regression'
              // 'linear' by default.
              // config: { method: 'linear', formulaOn: 'end'}
            }
          }
        ],
        title: {
          text: '工作日与Shannon-Wiener指数关系',
          left: 'center'
        },
        legend: {
          bottom: 5
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross'
          }
        },
        xAxis: {
          splitLine: {
            lineStyle: {
              type: 'dashed'
            }
          }
        },
        yAxis: {
          splitLine: {
            lineStyle: {
              type: 'dashed'
            }
          }
        },
        series: [
          {
            name: 'scatter',
            type: 'scatter'
          },
          {
            name: 'line',
            type: 'line',
            datasetIndex: 1,
            symbolSize: 0.1,
            symbol: 'circle',
            label: { show: true, fontSize: 16 },
            labelLayout: { dx: -20 },
            encode: { label: 2, tooltip: 1 }
          }
        ]
      };
      chart.setOption(option);
    }
  }
};
</script>

<style lang="scss" scoped>

.statistics-chart {
  width: 100%;
  height: 100%;
}
  .content-container{
    height: 380px;
  }
</style>